
local logic = {}

math.randomseed(tonumber(tostring(os.time()):reverse():sub(1,6)))

local ALL_CARDS_DATA = {
    0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,	-- 方块 A - K
	0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,	-- 梅花 A - K
	0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,	-- 红桃 A - K
	0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D	-- 黑桃 A - K
}

-- 获取洗牌后的扑克
-- cards_count:返回几张牌
function logic.shuffle(cards_count)
    local cards = table.clone(ALL_CARDS_DATA)
    local result = {}
    while cards_count > 0 do
        local pos = math.random(#cards)
        table.insert(result, cards[pos])
        table.remove(cards, pos)
        cards_count = cards_count - 1
    end
    return result
end

return logic
